def verify_password(password: str):
    if len(password) < 8:
        raise Exception("Password length must be at least 8 characters.")
    if not any(char.isdigit() for char in password):
        raise Exception("Password must contain at least one digit.")
    if not any(char.isalpha() for char in password):
        raise Exception("Password must contain at least one letter.")
    if not any(char.isupper() for char in password):
        raise Exception("Password must contain at least one upper case letter.")
    if not any(char.islower() for char in password):
        raise Exception("Password must contain at least one lower case letter.")
    print("Password is valid.")
    return True


try:
    password = input("Enter password: ")
    res = verify_password(password)
    if res == True:
        print("Login success.")
except Exception as e:
    print(e)
    print("Password is invalid.")

print("---------------------------------------")


# --------------------------------
# def login():
#     password = input("Enter password: ")
#     if len(password) >= 8:
#         return "success"
#     raise Exception("Password length must be at least 8 characters.")


# try:
#     login()
# except Exception as e:
#     print(e)
# finally:
#     print("finally..")

# print("Program end.")
